package com.app.backend.password.check.service;

import com.app.backend.common.aware.SpringContextAware;

import java.util.Map;

/**
 * 权益服务上下文
 *
 * @author Jet Zheng
 */
public class DecryptServiceContext {

    private Map<String, Class> handlerMap;

    public DecryptServiceContext(Map<String, Class> handlerMap) {
        this.handlerMap = handlerMap;
    }

    /**
     *
     * 获取解密实例
     *
     * @param type
     * @return
     */
    public DecryptService getCardInstance(String type) {
        Class clazz = handlerMap.get(type);
        if (clazz == null) {
            throw new IllegalArgumentException("not found handler for type: " + type);
        }
        return (DecryptService) SpringContextAware.getBean(clazz);
    }
}
